/*
 * Welcome to your app's main JavaScript file!
 *
 * We recommend including the built version of this JavaScript file
 * (and its CSS file) in your base layout (base.html.twig).
 */

// any CSS you require will output into a single css file (app.css in this case)
require('../sourse/style.css');

// Need jQuery? Install it with "yarn add jquery", then uncomment to require it.
// var $ = require('jquery');


$(document).ready(function() {
    $.localScroll();

    // $(".cache").delay(1000).fadeOut(500);
    // $("#wrapper-header").delay(1500).animate({opacity:'1',width:'100%'},500);
    $("#wrapper-navbar").delay(1000).animate({opacity:'1'},500);
    $("#main-container-image").delay(1000).animate({opacity:'1'},500);

});

/*TRANSITION PAGE*/

var speed = 'slow';

$('html, body').hide();

$(document).ready(function() {
    $('html, body').fadeIn(speed, function() {
        $('a[href], button[href]').click(function(event) {
            var url = $(this).attr('href');
            if (url.indexOf('#') == 0 || url.indexOf('javascript:') == 0) return;
            event.preventDefault();
            $('html, body').fadeOut(speed, function() {
                window.location = url;
            });
        });
    });
});

/* DISABLE HOVER EFFECT WHILE YOU SCROLL FOR A SMOOTHY NAVIGATION */

var body = document.body,
    timer;

window.addEventListener('scroll', function() {

    clearTimeout(timer);

    if(!body.classList.contains('disable-hover'))
        body.classList.add('disable-hover')

    timer = setTimeout(function(){
        body.classList.remove('disable-hover')
    }, 200);

}, false);

/* BOUTON MENU */

$(document).on('touchstart mouseover', '#stripes', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#stripes").stop().animate({scale:'1.2',opacity:'0.5'},300);

        event.handled = true;
    } else {
        return false;
    }
});

$(document).on('touchend mouseout', '#stripes', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#stripes").stop().animate({scale:'1',opacity:'1'},300);

        event.handled = true;
    } else {
        return false;
    }
});

/* MENU SIDE OPEN */

var MENUSIDEOPEN = document.getElementById('stripes');

MENUSIDEOPEN.addEventListener('click', function() {
    $("#main-container-menu").stop().animate({left:'0'},300);
});

/* BOUTON CROSS */

$(document).on('touchstart mouseover', '#cross-menu', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#cross-menu").stop().animate({scale:'1.2',opacity:'0.5'},300);

        event.handled = true;
    } else {
        return false;
    }
});

$(document).on('touchend mouseout', '#cross-menu', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#cross-menu").stop().animate({scale:'1',opacity:'1'},300);

        event.handled = true;
    } else {
        return false;
    }
});

// /* MENU SIDE CLOSE */
//
// var MENUSIDECLOSE = document.getElementById('cross-menu');
//
// MENUSIDECLOSE.addEventListener('click', function() {
// 			   $("#main-container-menu").stop().animate({'left':'-100%'},300);
// });

/* BOUTON MENU ARROW-2 */

$(document).on('touchstart mouseover', '#wrapper-title-2', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#fleche-nav-2").stop().animate({rotate: '90deg',opacity:'1'},300);

        event.handled = true;
    } else {
        return false;
    }
});

$(document).on('touchend mouseout', '#wrapper-title-2', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#fleche-nav-2").stop().animate({rotate: '0deg',opacity:'0.5'},300);

        event.handled = true;
    } else {
        return false;
    }
});

/* BOUTON MENU ARROW-3 */

$(document).on('touchstart mouseover', '#wrapper-title-3', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#fleche-nav-3").stop().animate({rotate: '90deg',opacity:'1'},300);

        event.handled = true;
    } else {
        return false;
    }
});

$(document).on('touchend mouseout', '#wrapper-title-3', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#fleche-nav-3").stop().animate({rotate: '0deg',opacity:'0.5'},300);

        event.handled = true;
    } else {
        return false;
    }
});

/* BOUTON MENU */

$(document).on('touchstart mouseover', '#stripes', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#stripes").stop().animate({scale:'1.2',opacity:'0.5'},300);

        event.handled = true;
    } else {
        return false;
    }
});

$(document).on('touchend mouseout', '#stripes', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#stripes").stop().animate({scale:'1',opacity:'1'},300);

        event.handled = true;
    } else {
        return false;
    }
});

/* BOUTON NEXT */

$(document).on('touchstart mouseover', '#oldnew-next', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#oldnew-next").stop().animate({scale:'1.2',opacity:'0.5'},300);

        event.handled = true;
    } else {
        return false;
    }
});

$(document).on('touchend mouseout', '#oldnew-next', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#oldnew-next").stop().animate({scale:'1',opacity:'1'},300);

        event.handled = true;
    } else {
        return false;
    }
});

/* BOUTON PREV */

$(document).on('touchstart mouseover', '#oldnew-prev', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#oldnew-prev").stop().animate({scale:'1.2',opacity:'0.5'},300);

        event.handled = true;
    } else {
        return false;
    }
});

$(document).on('touchend mouseout', '#oldnew-prev', function(event){

    event.stopPropagation();
    event.preventDefault();
    if(event.handled !== true) {

        $("#oldnew-prev").stop().animate({scale:'1',opacity:'1'},300);

        event.handled = true;
    } else {
        return false;
    }
});
// 下拉列表
function showlist () {

    if (document.getElementById('mylist').style.display == 'block')
        document.getElementById('mylist').style.display = 'none';
    else
        document.getElementById('mylist').style.display = 'block';



}